<template>
  <div class="">
    <div class="tabs-body">
      <el-switch :disabled="typeDisabled" v-model="indexTypeValue" active-value="2" inactive-value="1" active-color="#13ce66" inactive-color="#1890ff"
        active-text="转盘" inactive-text="默认首页" @change="typeChange">
      </el-switch>
      <div class="index_main">
        <div class="phone_box">
          <div class="header_img">
            <img src="@/static/douyin_header.png" alt />
            <div class="tixing"></div>
          </div>
          <img class="turntable_bj" src="@/static/turntable_bj.jpg" alt="" v-if="indexTypeValue==2">
          <div class="ph_main" v-if="indexTypeValue==1">
            <div class="all_play" @click="addBanner">
              <div class="all_play_banner_null" v-if="bannerList.length == 0">点击添加轮播图</div>
              <div class="all_play_banner" v-if="bannerList.length > 0">
                <el-carousel height="190px" indicator-position="outside" :interval="5000">
                  <el-carousel-item v-for="(item, index) in bannerList" :key="index + 'b'">
                    <img class="banner_img" :src="item.img" alt />
                  </el-carousel-item>
                </el-carousel>
              </div>
            </div>
            <div class="nav_box">
              <div class="kong_nav" v-if="navigationList.length == 0">
                <div class="list" v-for="(item, index) in 4" :key="index">+</div>
                <div class="status_edit">
                  <div class="editBox">
                    <el-button type="primary" @click="editNav">编辑</el-button>
                  </div>
                </div>
              </div>
              <div class="navList" v-else>
                <div class="list" v-for="(item, index) in navigationList" :key="index + 800">
                  <img :src="item.img" alt="">
                  <div class="txt">{{ item.title }}</div>
                </div>
                <div class="status_edit">
                  <div class="editBox">
                    <el-button type="primary" @click="editNav">编辑</el-button>
                  </div>
                </div>
              </div>
            </div>
            <div class="goods_box">
              <div class="statusBox">
                <div class="status_edit">
                  <div class="editBox">
                    <el-button type="primary" @click="addClass">编辑</el-button>
                  </div>
                </div>
                <!-- <img src="@/static/dy_status.png" alt=""> -->
                <div class="heaTable">
                  <div class="left">{{ leftTxt }}</div>
                  <div class="right">附近推荐</div>
                </div>
              </div>
              <div class="baoxiang">
                <div class="chestList">
                  <div class="property_box" v-for="(item, index) in punchActivityList" :key="index + 'p'">
                    <div class="property_box_h">
                      <div class="tou_in">
                        <img :src="item.shopLogo" alt="">
                        <p>{{ item.shopName }}</p>
                      </div>
                      <div class="jv_li">距您800m</div>
                    </div>
                    <div class="property_box_main">
                      <img class="property_box_l" :src="item.cover" alt="">
                      <div class="property_box_r">
                        <div class="property_box_r_title ">
                          <div class="zhelou" v-if="item.discount > 0 && item.discount < 7">
                            <img src="@/static/zhe_bg_1.png" alt="" />
                            <span>{{ item.discount }}折</span>
                          </div>
                          <p class="name ellipseHide_two" v-if="item.functionType == 4 || item.functionType == 3">{{
                            item.name }}</p>
                          <div class="property_box_r_title ellipseHide_two"
                            v-if="item.functionType == 1 || item.functionType == 2">{{ item.cardName }}</div>
                        </div>
                        <div class="property_box_r_detail_new">
                          <div class="mon_box">
                            <div class="money">
                              <span class="min_m">￥</span><span class="max_m">{{ item.price }}</span>
                              <span class="old_m" v-if="item.equityWorth && item.save > 0">￥{{ item.equityWorth }}</span>
                            </div>
                            <div class="shen_m" v-if="item.save > 0">共省{{ item.save }}元</div>
                          </div>
                          <div class="qiang_box" v-if="item.sellStatus">
                            <p class="p1">马上抢</p>
                            <p class="p2" v-if="item.give">立赚{{ item.give }}{{ item.giveType == 1 ? 'CoCo' : '椰分' }}</p>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <banner-diglog v-if="bannerDiglog" :visible.sync="bannerDiglog" @success="_handleSuccess" />
    <nav-diglog v-if="navDiglog" :visible.sync="navDiglog" @success="_handleSuccess" />
    <class-diglog v-if="classDiglog" :visible.sync="classDiglog" @success="_handleSuccess" />
  </div>
  </template>
  <script>
  import {
    advertiseList,
    navigationList,
    classificationList,
    classificationDetail,
    indexType,
    modifyIndexType,
  } from "@/api/incentiveManagement/dyConfig";
  import bannerDiglog from "./bannerDiglog";
  import navDiglog from "./navDiglog";
  import classDiglog from "./classDiglog";
  
  export default {
    name: "shopDetail",
    components: {
      bannerDiglog,
      navDiglog,
      classDiglog
    },
    props: {},
    data() {
      return {
        bannerList: [],
        navigationList: [],
        punchActivityList: [], //分类列表
        bannerDiglog: false,
        navDiglog: false,
        classDiglog: false,
        leftTxt: '神椰推荐',
        indexTypeValue:'1',//页面类型 1 正常页面 2 抽奖页面
        typeDisabled: false,
      };
    },
    watch: {},
    created() {
      this.getIndexType()
      this.getbannerList()
      this.getnavigation()
      this.getClassificationList()
      this.getDetail()
    },
    mounted() { },
    methods: {
      //获取首页类型
      getIndexType() {
        indexType().then((res) => {
          this.indexTypeValue = res.result.type
        });
      },
      //首页类型选择
      typeChange(){
        let data = {
          type: this.indexTypeValue
        }
        console.log(this.indexTypeValue)
        this.typeDisabled = true
        modifyIndexType(data).then((res) => {
          this.$message.success('操作成功');
          this.typeDisabled = false
          this.getIndexType()
        }).catch(()=>{
          this.typeDisabled = false
          this.getIndexType()
        })
      },
      //获取背景图
      getnavigation() {
        navigationList().then((res) => {
          this.navigationList = res.result
        });
      },
      //获取轮播图
      getbannerList() {
        advertiseList().then((res) => {
          this.bannerList = res.result;
        });
      },
      //NFR推荐列表
      getClassificationList() {
        classificationList().then((res) => {
          this.punchActivityList = res.result;
        });
      },
      //获取列表
      getDetail() {
        classificationDetail().then(res => {
          this.leftTxt = res.result.name
        })
      },
      //添加轮播图
      addBanner() {
        this.bannerDiglog = true;
      },
      //编辑分类导航
      editNav() {
        this.navDiglog = true
      },
      //编辑分类
      addClass() {
        this.classDiglog = true
      },
      _handleSuccess() {
        this.getbannerList()
        this.getnavigation()
        this.getClassificationList()
        this.getDetail()
      },
    },
  };
  </script>
  <style lang="scss" scoped>
  .tabs-body {
    background-color: #fff;
    padding: 20px;
  }
  
  .index_main {}
  
  .phone_box {
    width: 395px;
    min-height: 1000px;
    border-radius: 30px;
    border: 10px solid #333;
    margin: 40px 200px 0 100px;
    background: #f5f8fe;
    box-sizing: border-box;
    overflow: hidden;
  }
  
  .tixing {
    position: absolute;
    top: 0;
    left: 116px;
    width: 145px;
    height: 0;
    border-radius: 2px;
    border-top: 20px solid #333;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
  }
  
  .header_img {
    width: 100%;
    position: relative;
  
    img {
      width: 100%;
      border-top-left-radius: 30px;
      border-top-right-radius: 30px;
    }
  }
  .turntable_bj{
    width: 100%;
  }
  .ph_main {
    // padding: 0px 0 10px;
    background: #f2fbff;
  }
  
  .all_play {
    width: 100%;
    height: 210px;
    margin: 0 auto;
    position: relative;
    cursor: pointer;
  
    .all_play_nav {
      width: 100%;
      display: flex;
      align-items: center;
      overflow-x: hidden;
      white-space: nowrap;
      position: absolute;
      top: 46px;
      padding: 0 10px;
      box-sizing: border-box;
  
      .all_play_nav_box {
        height: 20px;
        border-radius: 100px;
        background: #ffffff;
        color: #333333;
        font-size: 12px;
        line-height: 20px;
        padding: 0 10px;
        margin-right: 20px;
      }
    }
  
    .all_play_banner_null {
      background-color: #eee;
      width: 100%;
      height: 100%;
      color: red;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  
    .all_play_banner {
      // padding: 10px 10px 0;
      position: relative;
      border-radius: 16px;
  
      .all_play_banner_title {
        color: #FFFFFF;
        font-size: 15px;
        position: absolute;
        top: 8px;
      }
  
      .banner_img {
        width: 100%;
        height: 100%;
      }
  
      .all_play_banner_status {
        width: 52px;
        height: 22px;
        background-color: rgba(0, 0, 0, 0.6);
        color: #ffffff;
        text-align: center;
        line-height: 22px;
        font-size: 12px;
        border-radius: 100px;
        position: absolute;
        top: 20px;
        left: 14px;
        z-index: 2;
      }
    }
  }
  
  .nav_box {
    width: 100%;
    height: 120px;
    padding: 0 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
  
    .kong_nav {
      width: 100%;
      display: flex;
      justify-content: space-between;
      position: relative;
  
      .list {
        width: 80px;
        height: 80px;
        border: 1px solid #ccc;
        border-radius: 4px;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 50px;
        color: #ccc;
      }
    }
  
    .kong_nav:hover {
      .status_edit {
        display: block;
      }
    }
  
    .navList {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      position: relative;
  
      .list {
        display: flex;
        flex: 1;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
  
        img {
          width: 52px;
          height: 52px;
        }
  
        .txt {
          margin-top: 8px;
          font-size: 12px;
          color: #333;
        }
      }
    }
  
    .navList:hover {
      .status_edit {
        display: block;
      }
    }
  }
  
  .status_edit {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 9;
    display: none;
    background: rgba(0, 0, 0, 0.4);
  
    .editBox {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
  
  .goods_box {
    background: #FFF7EF;
    border-radius: 20px 20px 0 0;
  
    .statusBox {
      width: 100%;
      height: 58px;
      position: relative;
  
      .heaTable {
        display: flex;
  
        .left {
          width: 50%;
          height: 58px;
          color: #fff;
          font-size: 20px;
          font-weight: 600;
          text-align: center;
          line-height: 58px;
          background: url('../../../../static/dy_status_left.png') no-repeat;
          background-size: 100% 100%;
        }
  
        .right {
          width: 50%;
          height: 58px;
          // background: url('../../../static/dy_status.png') no-repeat;
          // background-size: 100% 100%;
          color: #222;
          font-size: 20px;
          font-weight: 600;
          text-align: center;
          line-height: 58px;
        }
      }
  
      img {
        width: 100%;
        height: 100%;
      }
    }
  
    .statusBox:hover {
      .status_edit {
        display: block;
      }
    }
  }
  
  .baoxiang {
    margin-top: 10px;
  
    .chestList {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }
  
  }
  
  /* 资产列表star */
  .property {
    padding: 11px 15px 0;
  }
  
  .property_box {
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    padding: 15px 12px;
    margin-bottom: 14px;
    background-color: #ffffff;
    width: 345px;
  }
  
  .property_box_h {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid#E1E1E1;
    height: 50px;
  
    .tou_in {
      display: flex;
      justify-content: flex-start;
      align-items: center;
  
      img {
        width: 28px;
        height: 28px;
        border-radius: 4px;
        margin-right: 8px;
      }
    }
  
    .jv_li {
      border: 1px solid #C4BFFF;
      padding: 0 3px;
      border-radius: 3px;
      height: 20px;
      line-height: 20px;
      color: #4738FA;
      font-size: 12px;
    }
  }
  
  .property_box_main {
    display: flex;
    padding-top: 12px;
  }
  
  .property_box_l {
    width: 92px;
    height: 95px;
    border-radius: 4px;
  }
  
  .property_box_r {
    flex: 1;
    padding: 0 0 0 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  
  .property_box_r_title {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 7px;
  
    // height: 44px;
    .name {
      font-size: 15px;
      color: #222222;
      font-weight: bold;
      line-height: 22px;
      margin-left: 8px;
      flex: 1;
      width: 0;
    }
  
    .zhelou {
      width: 44px;
      height: 20px;
      position: relative;
  
      img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
  
      span {
        display: block;
        width: 100%;
        height: 20px;
        line-height: 20px;
        text-align: center;
        color: #FF2521;
        font-size: 11px;
        padding-left: 10px;
        position: relative;
      }
    }
  }
  
  .property_box_r_money {
    font-size: 13px;
    color: #ff3a3a;
  }
  
  .current_price {
    font-size: 17px;
    color: #ff3a3a;
    font-weight: bold;
  }
  
  .original_price {
    color: #838285;
    font-size: 12px;
    text-decoration: line-through;
    margin-left: 4px;
  }
  
  .property_box_r_buy {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .property_box_r_buy_button {
    width: 70px;
    height: 24px;
    border-radius: 100px;
    background: #ffeec3;
    color: #ef2d29;
    font-size: 14px;
    text-align: center;
    line-height: 24px;
  }
  
  .property_box_r_detail {
    display: flex;
    align-items: center;
    border-radius: 50px;
    height: 30px;
    margin-top: 8px;
  }
  
  .property_box_r_detail_l {
    background: linear-gradient(108deg, #ffa644 11.85%, #eb3d3c 54.64%);
    color: #ffffff;
    font-size: 13px;
    display: flex;
    align-items: center;
    padding: 0 13px 0 12px;
    height: 30px;
    border-radius: 50px 0 0 50px;
    margin-right: -6px;
    line-height: 30px;
  }
  
  .exclamation_point_img {
    width: 17px;
    height: 17px;
    margin-left: 4px;
  }
  
  .property_box_r_detail_r {
    background: url("/static/property_box_r_detail_r.png") no-repeat;
    background-size: 100% 100%;
    color: #ef2d29;
    font-size: 13px;
    height: 31px;
    text-align: center;
    line-height: 31px;
    width: 89px;
    border-radius: 0 50px 50px 0;
  }
  
  .property_box_r_detail_new {
    widows: 220px;
    height: 40px;
    // background: #FCF4F0;
    // border-radius: 100px;
    display: flex;
    justify-content: space-between;
    overflow: hidden;
  
    .mon_box {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: flex-start;
      margin-left: 10px;
  
      .money {
        display: flex;
        justify-content: flex-start;
        align-items: baseline;
  
        .min_m {
          font-size: 12px;
          color: #FF3A3A;
        }
  
        .max_m {
          font-size: 19px;
          font-weight: 600;
          color: #FF3A3A;
        }
  
        .old_m {
          font-size: 12px;
          color: #B67E7E;
          text-decoration: line-through;
          margin-left: 4px;
        }
      }
  
      .shen_m {
        font-size: 12px;
        color: #FF3A3A;
      }
    }
  
    .qiang_box {
      background: linear-gradient(90deg, #EA664B -9.85%, #EA4B3D 100.5%);
      // width: 102px;
      height: 36px;
      border-radius: 100px;
      padding: 0 6px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      position: relative;
  
      // background: url("../../../../static/qiang_bg.png") no-repeat;
      .p1 {
        font-size: 14px;
        font-weight: 600;
        color: #fff;
        position: relative;
        z-index: 99;
      }
  
      .p2 {
        font-size: 11px;
        color: #fff;
        position: relative;
        z-index: 99;
      }
  
      img {
        width: 102px;
        height: 40px;
        position: absolute;
        top: 0;
        left: 0;
      }
    }
  }
  
  /* 资产列表end */</style>
    